package com.panopset.app;

import java.io.File;
import java.io.IOException;
import java.nio.file.CopyOption;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;

import com.panopset.io.DirectoryProcessor;

public class ToLowerCaseFiles {

    /**
     * @param args
     */
    public static void main(String[] args) {
        new ToLowerCaseFiles().go(new File("C:/apps/installs/svgc"));
    }

    void go(File d) {
        new DirectoryProcessor(d) {

            @Override
            protected void process(File source) {
                if (Files.isSymbolicLink(source.toPath())) {
                    return;
                }
                try {
                    if (source.isDirectory()) {
                        for (File f : source.listFiles()) {
                            new ToLowerCaseFiles().go(f);
                        }
                    } else {
                        File parent = source.getParentFile();
                        File target = new File(parent.getCanonicalPath() + "/c" + source.getName().toLowerCase());
                        source.renameTo(target);
                    }
                } catch(IOException ex) {
                    ex.printStackTrace();
                }
            }
        }.exec();
    }
}
